package com.dave.gd.core.common.globalsession.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@SuppressWarnings("serial")
public class RedirectServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
        StringBuffer sb = new StringBuffer();
        sb.append("http://").append(request.getServerName()).append(":");
        if (request.getServerPort() == 8080) {
            sb.append("8070");
        } else {
            sb.append("8080");
        }
        sb.append(request.getContextPath());
        sb.append("/index.jsp");
        System.out.println("sb.****" + sb.toString());
        
        // 跳转到另外一个tomcat容器中
        response.sendRedirect(sb.toString());
    }
    
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
        doGet(req, resp);
    }
    
}
